import java.util.Arrays;

/**
 * @Author ZhangCuirong
 * @Date 2025/9/12 10:28
 * @description:
 */
public class LCR139 {
    public int[] trainingPlan(int[] actions) {
        int fast = 0, slow = 0;
        while (fast < actions.length) {
            if (actions[fast] % 2 == 1) {
                int temp = actions[slow];
                actions[slow] = actions[fast];
                actions[fast] = temp;
                slow++;
            }
            fast++;

        }
        return actions;
    }
    //这样能保持相对顺序
    public int[] trainingPlan2(int[] actions) {
        int n = actions.length;
        int[] result = new int[n];
        int index = 0;

        // 第一次遍历：放奇数
        for (int num : actions) {
            if (num % 2 == 1) {
                result[index++] = num;
            }
        }

        // 第二次遍历：放偶数（保持原有顺序）
        for (int num : actions) {
            if (num % 2 == 0) {
                result[index++] = num;
            }
        }

        return result;
    }

    public static void main(String[] args) {
        LCR139 lc139 = new LCR139();
        System.out.println(Arrays.toString(lc139.trainingPlan(new int[]{1, 2, 3, 4, 5})));
    }
}
